Skip to content

gh-155860: Reject a detached window in panel.replace() - #155861

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
fedonman:fix-panel-replace-null-window
Aug 16, 2026
Merged

gh-155860: Reject a detached window in panel.replace()#155861
serhiy-storchaka merged 1 commit into
python:mainfrom
fedonman:fix-panel-replace-null-window

Conversation

@fedonman

@fedonman fedonman commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Reject a window detached by curses.screen.close() in panel.replace(), raising curses.panel.error the way new_panel() already does, and add a regression test. new_panel() needs no change: it already rejects that window.

$ ./python -m test test_curses -u curses
Total tests: run=169 skipped=3
Result: SUCCESS

No NEWS entry: screen.close() is new in 3.16 and unreleased, so no released version can reach the crash.

curses.screen.close() detaches the screen's standard window: the wrapper
object stays alive but the curses window behind it is gone.
panel.replace() did not check for that, so it stored the detached window
in the panel and curses dereferenced it on the panel's next use, killing
the interpreter with SIGSEGV.  Raise curses.panel.error instead, the way
new_panel() already does on the same window.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34083186 | 📁 Comparing 110da9d against main (948fd7e)

  🔍 Preview build  

1 file changed
± library/curses.panel.html

@serhiy-storchaka
serhiy-storchaka self-requested a review August 15, 2026 20:34

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@serhiy-storchaka
serhiy-storchaka merged commit 89e3aae into python:main Aug 16, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants